package com.qfedu.zf.app.controller;

import com.qfedu.zf.app.service.PostPageFeign;
import com.qfedu.zf.common.param.CommentCreatDTO;
import com.qfedu.zf.common.param.PostPage;
import com.qfedu.zf.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- 天道酬勤 ---
 *
 * @author WangJingwen
 * @date 2024/6/20
 * @desc -- 代码敲烂 月薪过万--
 * @desc
 */
@RestController
@RequestMapping("/api/life/postPage")
public class PostPageController {


    @Autowired
    private PostPageFeign postPageFeign;


    @GetMapping("/all")
    public List<PostPage> getAllPosts() {
        return postPageFeign.getAllPosts();
    }



    @GetMapping("/{postPageId}")
    public List<com.qfedu.zf.common.param.PostDetails> selectPostsDetailById(@PathVariable("postPageId") Long postPageId) {

        return postPageFeign.selectPostsDetailById(postPageId);
    }

    @PostMapping("/{postPageId}/like")
    public void likePost(@PathVariable("postPageId") Long postPageId) {
        postPageFeign.likePost(postPageId);
    }

    /**
     * 获取所有评论
     * @return
     */
    @GetMapping("/{postPageId}/commentList")
    public R getAllComment(@PathVariable("postPageId") Long postPageId) {
        return postPageFeign.getAllComment(postPageId);
    }

    @PostMapping("/{postPageId}/addComment")
    public R addComment(@PathVariable("postPageId") Long postPageId,@RequestBody CommentCreatDTO commentCreatDTO) {
        return postPageFeign.addComment(postPageId ,commentCreatDTO);
    }
}
